package com.example.demolearn.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class ServiceExceptionHandler {

    @Around("@annotation(com.example.demolearn.annotation.ServiceExceptionCatch)")
    public Object handleServiceException(ProceedingJoinPoint pjp) throws Throwable {
        try {
            // 捕捉运行异常
            Object result = pjp.proceed();
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
            throw e;
        }
    }

}
